<?php

/**
 * 
 * Enter description here ...
 * @author ysahn
 *
 */
class Service_PostServiceStub extends Service_GenericSeedniaServiceStub
{
	
	// localhost:8080/seednia-webapp/ws/PostServiceRest/post/
	// contentType = application/json, application/x-www-form-urlencoded
	public function __construct($serviceUriRoot, $accessToken, $contentType = 'application/x-www-form-urlencoded')
	{
		parent::__construct($serviceUriRoot, $accessToken, $contentType);
	}
	
	public function getPostList($criteria, $offset, $max)
	{
		if ($criteria == null)
			$criteria = array();
		
		//$criteria['creatorSid'] = $this->_sessionInfo->userInfo['userSid'];
		
		return parent::getList($criteria, $offset, $max);
	}

	/**
	 * 
	 * Enter description here ...
	 * @param long $userSid
	 * @param string $body
	 * @param arr(string) $tags
	 */
	public function addPost($projectSid, $body, $tags)
	{
		$tagsNamesCsv = "";
		if (is_array($tags)) {
			$tagsNamesCsv = implode(",", $tags);
		} else {
			$tagsNamesCsv = $tags;
		}
		// TODO: something is wrong here...
		$fields = array('projectSid' => $projectSid, 'body' => $body, 'postTagNamesCsv' => $tagsNamesCsv);
		return parent::add($fields);
	}
}